package com.msstudio;

// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 

import com.msstudio.utils.PkgTools;
import com.msstudio.utils.HttpPosterListener;
import com.msstudio.midlets.MSCMIDlet;
import javax.microedition.lcdui.*;

public class SendMsgDlg
    implements CommandListener, HttpPosterListener
{

    protected Command cmdOk;
    protected Command cmdCancel;
    protected Command cmdAgain;
    protected Command cmdContinue;
    private String strDestUin;
    private String strMsgBody;
    private TextBox form;

    public SendMsgDlg()
    {
        cmdOk = null;
        cmdCancel = null;
        cmdAgain = null;
        cmdContinue = null;
        strDestUin = null;
        strMsgBody = null;
        form = null;
    }

    public void init()
    {//�Ա�����Ҫ�õ���һЩ�������г�ʼ����
        cmdOk = new Command(MSCMIDlet.multiLang.sSend, 1, 1);
        cmdCancel = new Command(MSCMIDlet.multiLang.sCancel, 2, 2);
        cmdAgain = new Command(MSCMIDlet.multiLang.sYes, 1, 1);
        cmdContinue = new Command(MSCMIDlet.multiLang.sContinue, 1, 1);
        form = new TextBox(MSCMIDlet.multiLang.sSendMessage, "", 100, 0);
        form.addCommand(cmdOk);
        form.addCommand(cmdCancel);
        form.setCommandListener(this);
    }

    public void show(long l, boolean flag)
    {//��ʾ������Ϣ���棻
        if(flag)
        {//���������������л�������Ľ�����˻ص�������Ϣ�Ľ���ʱ����ʾ��ǰ
         //���������ݣ�
            form.setString(strMsgBody);
        } else
        {//���ǿ�ʼ�����µ���Ϣ����������Ϣ������Ϊ��
            strDestUin = Long.toString(l);
            form.setString("");
        }
        MSCMIDlet.display.setCurrent(form);//��ʾ������Ϣ���棻
    }

    private void doSend()
    {//���ͺ�����Ϣ�Ѿ����룬��ʼ���Ͳ�����
        strMsgBody = form.getString();//ȡ����Ҫ���͵���Ϣ���ݣ�
        if(strMsgBody.length() < 1)
        {//��δ������Ϣ����
            MSCMIDlet.instance.showMessage(MSCMIDlet.multiLang.sSendFall, MSCMIDlet.multiLang.sCanNotSendNull, this, cmdContinue, cmdCancel);
            return;
        } else
        {//����������Ϣ���ݣ��򽫸���Ϣ���ͳ�ȥ��
            MSCMIDlet.httpPoster.sendMsg(strDestUin, PkgTools.Encodecgi(strMsgBody), this);
            MSCMIDlet.historyMsg.appendComSendMsg(strDestUin, strMsgBody);
            MSCMIDlet.mainForm.show();
            return;
        }
    }

    public void commandAction(Command command, Displayable displayable)
    {
        if(command == cmdOk)
            doSend();
        else
        if(command == cmdAgain)
            show(0L, true);
        else
        if(command == cmdCancel)
            MSCMIDlet.mainForm.show();
        else
        if(command == cmdContinue)
            MSCMIDlet.display.setCurrent(form);
    }

    public void receiveHttpResponse(String s)
    {//�ӿں���ӿڵ��ã��˽ӿں�����HttpPosterListener.java�б����壻
        String s1 = PkgTools.GetParaVal("CMD", s).toUpperCase();
        String s2 = PkgTools.GetParaVal("RES", s);
        if(s1.equals("CLTMSG") && s2.equals("0"))
        {
            MSCMIDlet.getMsgDlg.updateTimerSet(0);
            MSCMIDlet.friendList.showInfor(MSCMIDlet.multiLang.sSended);
        }
    }

    public void handleHttpError(String s)
    {//�ӿں���ӿڵ��ã��˽ӿں�����HttpPosterListener.java�б����壻
    }
}
